<template>
  <div class="test">
    <p>我是test页面</p>
    <router-link to='/b'>去子页面</router-link>
    <button @click="toBpage">点击我传参至b页面并且跳转至b页面(通过path和query)</button>
    <button @click="toBpage2">点击我传参至b页面并且跳转至b页面(通过name和params)</button>
  </div>
</template>

<script>
export default {
  name: 'test',
  data:function(){
    return{
      str:'我是test页面传来的字符串'
    }
  },
  methods:{
    toBpage(){
      this.$router.push({
        path:'/b',
        query:{
          id:1,
          name:'test'
        }
      })
    },
    toBpage2(){
      this.$router.push({
        name:'b',
        params:{
          id:2,
          name:'test2'
        }
      })
    }
  }
}
</script>
